package com.db;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;


public class MainTabActivity extends TabActivity{
	
	
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);

	    TabHost tabHost = getTabHost();  // The activity TabHost
	    TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, AskTab.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    //spec = tabHost.newTabSpec("Ask").setIndicator("Ask",getResources().getDrawable(R.drawable.ask_tab_icon)).setContent(intent);
	    spec = tabHost.newTabSpec("Ask").setIndicator("").setContent(intent);
	    tabHost.addTab(spec);

	    
	    // Do the same for the other tabs
	    intent = new Intent().setClass(this, NewsTab.class);
	    //spec = tabHost.newTabSpec("News").setIndicator("News",getResources().getDrawable(R.drawable.news_tab_icon)).setContent(intent);
	    spec = tabHost.newTabSpec("News").setIndicator("").setContent(intent);
	    tabHost.addTab(spec);



	    // Do the same for the other tabs
	    intent = new Intent().setClass(this, InstructionsTab.class);
	    //spec = tabHost.newTabSpec("Instructions").setIndicator("Instructions",getResources().getDrawable(R.drawable.instructions_tab_icon)).setContent(intent);
	    spec = tabHost.newTabSpec("Instructions").setIndicator("").setContent(intent);
	    tabHost.addTab(spec);
	    
	    // Do the same for the other tabs
	    intent = new Intent().setClass(this, AboutTab.class);
	    //spec = tabHost.newTabSpec("About").setIndicator("About",getResources().getDrawable(R.drawable.about_tab_icon)).setContent(intent);
	    spec = tabHost.newTabSpec("About").setIndicator("").setContent(intent);
	    tabHost.addTab(spec);
	    
	    tabHost.getTabWidget().getChildTabViewAt(0).setBackgroundResource(R.drawable.ask_tab_xml);
	    tabHost.getTabWidget().getChildTabViewAt(1).setBackgroundResource(R.drawable.news_tab_xml);
	    tabHost.getTabWidget().getChildTabViewAt(2).setBackgroundResource(R.drawable.instructions_tab_xml);
	    tabHost.getTabWidget().getChildTabViewAt(3).setBackgroundResource(R.drawable.about_tab_xml);
	    

	    tabHost.setCurrentTab(4);
	}
	
	
	@Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        //save state
        Log.d("onSaveInstanceState", "Saving State");
        
    }
	
	@Override
    protected void onPause() {
        super.onPause();
        //save state
        Log.d("onPause", "Saving State");
    }
	
	@Override
    protected void onResume() {
        super.onResume();
        //load state
        Log.d("onResume", "Loading State");
    }
	
	@Override
    protected void onStop() {
        super.onStop();
        Log.d("App Destroy", "SHUTTING DOWN");
    }

}
